<!--suppress ALL -->
<include file="./Template/header.html" />
<link rel="stylesheet" type="text/css" href="/Template/css/messagebox.css?v=20201007">
<script type="text/javascript">

    $(function() {

        //初始化页面配置
        initPage("咨询");

        var app = new Vue({
            el: '#container',
            data: {
                info: [],
            },
            methods: {

                index: indexPage,
                cancel: function() {
                    window.location.href = "/wechat";
                },
                save: function() {

                    var messageId = $("input[name=messageId]").val();
                    var customerId = $("input[name=customerId]").val();
                    var number = $("input[name=number]").val();
                    var fullname = $("input[name=fullname]").val();
                    var enterprise = $("input[name=enterprise]").val();
                    var messageContent = $("textarea[name=messageContent]").val();
                    var note = $("textarea[name=note]").val();

                    var checkboxs = $("input.checkItem");
                    var productList = "";
                    for (var i = 0; i < checkboxs.length; i++) {
                        if(checkboxs[i].checked == true){
                            if(productList != ""){
                                productList += ",";
                            }
                            productList += checkboxs[i].name;
                        }
                    }

                    if(isNullOrEmpty(fullname)) {
                        alert("请填写姓名");
                        return false;
                    }

                    if(isNullOrEmpty(number)) {
                        alert("请填写联系电话");
                        return false;
                    }
                    if(!checkPhone(number)) {
                        alert("联系电话位数不对");
                        return false;
                    }
                    if(isNullOrEmpty(enterprise)) {
                        alert("请填写企业或机构名");
                        return false;
                    }
                    if(isNullOrEmpty(productList)) {
                        alert("请选择业务产品");
                        return false;
                    }
                    if(isNullOrEmpty(messageContent)) {
                        alert("请填写功能需求");
                        return false;
                    }



//                    if(isNullOrEmpty(productId)) {
//                        alert("请选择产品");
//                        return false;
//                    }

                    $(".save-btn").hide();

                    $.ajax({
                        url:"/wechat/Messagebox/updateMessagebox",
                        type:"post",
                        data:{
                            messageId: messageId,
                            customerId: customerId,
                            enterprise: enterprise,
                            number: number,
                            productList: productList,
                            fullname: fullname,
                            messageContent: messageContent,
                            note: note,
                        },

                        dataType:"JSON",
                        beforeSend:function(){
                            $("#loadingToast").show();
                        },
                        complete:function(){
                            $('#loadingToast').hide();
                        },
                        success:function(data){
                            if(data.code == 200) {
                                alert("提交成功");
                                window.location.href = "/wechat/";
                            }
                        },
                    })

                }

            }
        })

        $(".item select").change(function() {
            var value = $(this).find("option:selected").text();
            $(this).prev().val(value);
        });

        $("input[type=date]").change(function() {
            var value = $(this).val();
            $(this).prev().val(value);
        });

    });


</script>
<div class="hint-info" style="height: 3rem;padding: 5px 10px 5px 10px; font-size: 0.9rem; line-height: 1.2rem">
    请如实填写相关信息, 提交成功后, 可获得三年内每年5000元优惠券, 用于抵扣部分平台租赁或定制开发费用
</div>
<div class="edit-content">
    <input type="text" style="display: none;" name="messageId" value="{$info.messagebox_id}">
    <input type="text" style="display: none;" name="customerId" value="{$customerId}">
    <div class="item">
        <span>姓名</span>
        <input type="text" name="fullname" value="{$info.fullname}" placeholder="请填写您的姓名">
        <img class="icon-right" src="/Template/images/icon-right.png" alt="">
    </div>
    <div class="item">
        <span>联系电话</span>
        <input type="text" name="number" value="{$info.number}" placeholder="请填写您的电话号码">
        <img class="icon-right" src="/Template/images/icon-right.png" alt="">
    </div>
    <div class="item">
        <span>企业或机构名</span>
        <input type="text" name="enterprise" value="{$info.enterprise}" placeholder="请填写您的企业或机构名">
        <img class="icon-right" src="/Template/images/icon-right.png" alt="">
    </div>
    <div style="height: 8rem;line-height: 2.5rem" class="item" id="productCheck">
        <span>业务产品：</span>
        <br/>
            <label class="checkbox inline">
                <php>
                    $listArr = explode(",",$info["product_list"]);
                    $nameArr = array("上肢矫形器","下肢矫形器","脊柱矫形器","假肢","成品销售","其它");
                    $check = array();
                    for($i = 0;$i < 7;$i++){
                    $check[$i] = in_array($nameArr[$i],$listArr)?"checked":"";
                    }
                </php>
                <input class="checkItem" type="checkbox" name="上肢矫形器" {$check.0}>上肢矫形器&nbsp;&nbsp;&nbsp;&nbsp;
                <input class="checkItem" type="checkbox" name="下肢矫形器" {$check.1}>下肢矫形器&nbsp;&nbsp;&nbsp;&nbsp;
                <input class="checkItem" type="checkbox" name="脊柱矫形器" {$check.2}>脊柱矫形器
                <br/>
                <input class="checkItem" type="checkbox" name="假肢" {$check.3}>假肢&nbsp;&nbsp;&nbsp;&nbsp;
                <input class="checkItem" type="checkbox" name="成品销售" {$check.4}>成品销售&nbsp;&nbsp;&nbsp;&nbsp;
                <input class="checkItem" type="checkbox" name="其它" {$check.5}>其它
            </label>
    </div>
    <div class="title-span">
        <span>功能需求</span>
    </div>
    <div class="area">
        <textarea class="t-area" name="messageContent" placeholder="请填写您的功能需求">{$info.message_content}</textarea>
    </div>
    <div class="title-span">
        <span>其它</span>
    </div>
    <div class="area">
        <textarea class="t-area" name="note" placeholder="请填您的其他留言">{$info.note}</textarea>
    </div>
</div>

<div class="operation-btn">
    <div class="cancel-btn" v-on:click="cancel">取消</div>
    <div class="save-btn" v-on:click="save">提交</div>
</div>
<include file="./Template/footer.html" />

